import Storage from "@/libs/Storage";
import {orderApi} from "../api";

let _orderId;
export default {
  setOrderId(orderId) {
    _orderId = orderId
  },
  async openJoint(id) {
    if (!_orderId) {
      console.log('_orderId 不存在')
      return
    }
    console.log('try open joint', _orderId, id)

    const key = _orderId + '_' + id
    if (!await Storage.get(key)) {
      await Storage.set(key, 1)
      console.log('open new joint1', _orderId, id)
      await orderApi.addPercent(_orderId)

    } else {
      console.log('opened joint', _orderId, id)
    }
  }
}